package br.com.winesys.geta.databinding.componentBinder;

import javax.swing.JCheckBox;
import br.com.winesys.geta.databinding.ComponentBinder;

public final class JCheckBoxBinder implements ComponentBinder<JCheckBox> {

	private static final ComponentBinder<JCheckBox> INSTANCE = new JCheckBoxBinder();

	public static ComponentBinder<JCheckBox> getInstance() {
		return INSTANCE;
	}

	private JCheckBoxBinder() {
	}

	@Override
	public Object read(JCheckBox component) {
		return component.isSelected();
	}

	@Override
	public void write(JCheckBox component, Object value) {
		if (value != null) {
			component.setSelected((Boolean) value);
		} else {
			component.setSelected(false);
		}
	}
}
